#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "minunit.h"
#include "student.h"

// 声明外部测试计数器
extern int tests_run;

#define TAG "【学生模块】"
#define STR_HELPER(x) #x
#define STR(x) STR_HELPER(x)
#define TAG_MSG(msg) TAG STR(msg)
// 测试学生创建与销毁
char *test_student_creation() {
    Student *student = student_create("张三", 1, 95.5);
    mu_assert(TAG_MSG(创建学生失败), student != NULL);
    mu_assert(TAG_MSG(姓名不匹配), strcmp(student_get_name(student), "张三") == 0);
    mu_assert("学号不匹配", student_get_id(student) == 1);
    mu_assert("分数不匹配", student_get_score(student) == 95.5f);
    
    student_destroy(student);
    return NULL;
}

// 测试学生信息修改
char *test_student_modification() {
    Student *student = student_create("李四", 2, 88.0);
    student_set_name(student, "李四改");
    student_set_score(student, 90.5);
    
    mu_assert("姓名修改失败", strcmp(student_get_name(student), "李四改") == 0);
    mu_assert("分数修改失败", student_get_score(student) == 90.5f);
    
    student_destroy(student);
    return NULL;
}

// 测试中文姓名支持
char *test_chinese_name() {
    Student *student = student_create("王小明", 3, 75.0);
    mu_assert("中文姓名存储失败", strcmp(student_get_name(student), "王小明") == 0);
    
    student_set_name(student, "李小华");
    mu_assert("The modification of the Chinese name failed.", strcmp(student_get_name(student), "李小华") == 0);
    
    student_destroy(student);
    return NULL;
}

// 学生模块测试套件
char *test_student_suite() {
    mu_run_test(test_student_creation);
    mu_run_test(test_student_modification);
    mu_run_test(test_chinese_name);
    return NULL;
}